1. Field of the Invention
The present invention relates to an image processing apparatus, and in particular to an image processing apparatus and a control method therefor that carry out demosaicing by interpolating missing color signals for each pixel in a color image signal, as well as a computer-readable storage medium storing a program for causing a computer to execute the method.
2. Description of the Related Art
Conventionally, in a color image sensor, color filters in a Bayer pattern as shown in FIG. 19 are used. As the color filters, filters of three primary colors, i.e. red, green, and blue, or three complementary colors, i.e. cyan, magenta, and yellow are used.
In the Bayer pattern, however, only a color signal of one color can be obtained in each pixel, and hence a process is carried out in which color signals of the other two colors missing in each pixel are demosaiced (interpolated). As the demosaicing method, a number of methods have been conventionally known, and bi-linear interpolation and bi-cubic interpolation are known as basic demosaicing methods.
The bi-linear interpolation and the bi-cubic interpolation can obtain favorable interpolation results in, for example, an image including a number of low-frequency components, but causes false color called moiré, which does not exist in a real subject, to appear in an image including a number of high-frequency components. The false color results from demosaicing using pixels in a direction other than the direction of an edge which a subject image originally has.
Thus, there has been proposed a demosaicing method using pixels along the direction of an edge which a subject image originally has. This demosaicing method using pixels along the direction of an edge can be broadly divided into two methods. In Japanese Laid-Open Patent Publication (Kokai) No. 2002-300590, there has been proposed a method in which the direction of an edge is determined using neighboring pixels, and interpolation is carried out along the edge without carrying out interpolation in such a direction as to cross the edge.
Also, in Japanese Laid-Open Patent Publication (Kokai) No. 2002-300590, there has been proposed a method in which saturations are calculated using a pixel targeted for interpolation and its neighboring pixels, and a direction in which the saturation is small is adaptively selected so as to improve an accuracy of edge direction determination. On the other hand, in Japanese Laid-Open Patent Publication (Kokai) No. 2008-035470, there has been proposed a method in which interpolation is carried out first on a direction-by-direction basis to generate a plurality of kinds of interpolation results, and then a direction in which an appropriate interpolation result has been obtained is determined and selected.
In Japanese Laid-Open Patent Publication (Kokai) No. 2008-035470, there has been proposed an interpolation method in which an evaluation value called peripheral similarity indicative of the homogeneity of a pixel targeted for interpolation and its neighboring pixels is introduced for the determination about the appropriateness of an interpolating direction, and a direction in which the homogeneity is high is selected as an edge direction.
However, according to the method disclosed in Japanese Laid-Open Patent Publication (Kokai) No. 2002-300590, although false colors in a gray-scale subject having high-frequency components can be reduced, there is concern that an interpolation error resulting from an erroneous judgment occurs in a case of a subject having high-frequency components whose base is colored.
On the other hand, according to the method disclosed in Japanese Laid-Open Patent Publication (Kokai) No. 2008-035470, there may be a case where a false color with low-frequency components having high homogeneity is selected by mistake.